﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MenuList.ascx.cs" Inherits="AdminPortal_Controls_Menu_MenuList" %>
<%@ Register src="../Toolbox.ascx" tagname="Toolbox" tagprefix="uc1" %>
<script>
    $(function () {
        //mouseover line on gird
        $('#HNGdatagrid tbody >tr:not(:first)').mouseover(function () {
            $(this).css('background-color', '#fdf3eb');
        });
        $('#HNGdatagrid tbody >tr:not(:first)').mouseout(function () {
            $(this).css('background-color', '#fff');
        });

        //Show hide button Order
        ShowOrderButton();
    });

    //change OrderUp
    function OrderUp(orID) {
        var urlOrderUp = '<%=Page.ResolveUrl("~/AdminPortal/Controls/Menu/Ajax/Menu_UpdateOrdersUp.ashx?id=") %>' + orID;
        $.ajax({
            url: urlOrderUp,
            success: function (data) {
                if (parseInt(data) > -1) {
                    location.href = "MenuList.aspx";
                }
            }
        });
    }
    //change OrderDown
    function OrderDown(orID) {
        var urlOrderDown = '<%=Page.ResolveUrl("~/AdminPortal/Controls/Menu/Ajax/Menu_UpdateOrdersDown.ashx?id=") %>' + orID;
        $.ajax({
            url: urlOrderDown,
            success: function (data) {
                if (parseInt(data) > -1) {
                    location.href = "MenuList.aspx";
                }
            }
        });
    }

    //change status
    function changeStatusMenu(imgName, cateID) {
        var urlUpdateStatus = '<%=Page.ResolveUrl("~/AdminPortal/Controls/Menu/Ajax/Menu_UpdateStatus.ashx?id=") %>' + cateID;
        var img = $('#' + imgName);
        img.fadeOut();
        $.ajax({
            url: urlUpdateStatus,
            success: function (data) {
                if (data == 'true') {
                    img.attr('src', '<%=Page.ResolveUrl("~/AdminPortal/Images/Icon/tree_dnd_yes.png") %>');
                } else {
                    img.attr('src', '<%=Page.ResolveUrl("~/AdminPortal/Images/Icon/tree_dnd_no.png") %>');
                }
            }
        });
        img.fadeIn();
    }

    //Show button change Order
    function ShowOrderButton() {
        $('img[nameImg=imgOrderUp]:first').hide();
        $('img[nameImg=imgOrderDown]:last').hide();
    }
</script>
<div style="padding-top:20px;">
Có: <asp:Label ID="lblTotalRecord" runat="server"></asp:Label> menu    
</div>
<div id="HNGdatagrid">
    <div class="header-datagrid">
        <span class="icon-list header-text">Danh sách menu</span>
    </div>
    <div class="navibar-control">
        <div style="float:left;">
            <uc1:Toolbox ID="Toolbox1" runat="server" ShowAdd="true" OnAddClick="btnAdd_Click"
                                                      ShowDel="true" OnDelClick="btnDel_Click"
                                                      ShowSearch="true" OnSearchClick="btnSearch_Click"
                                                      ShowRefesh="true"  />
        </div>
        <div style="float:right;padding-right:10px;padding-top:10px;">
            Từ khoá: <asp:TextBox ID="txtKeySearch" runat="server" Width="250"></asp:TextBox>
            Danh mục cha: <asp:DropDownList ID="ddlDanhMucCha" runat="server" 
                AutoPostBack="True" onselectedindexchanged="ddlDanhMucCha_SelectedIndexChanged"></asp:DropDownList>
        </div>
        <div class="clearB"></div>
    </div>
    <div class="content-datagrid">        
        <asp:GridView ID="dgvMenuList" runat="server" 
            AutoGenerateColumns="False" EnableModelValidation="True" GridLines="None" 
            onrowdatabound="dgvMenuList_RowDataBound">
            <Columns>
                 <asp:TemplateField HeaderText="#" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="30">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="30" >
                    <HeaderTemplate>                    
                        <input id="chkAll" type="checkbox" name="chkAll" onclick="javascript:SelectAllCheckboxes(this);"/>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input id="chkID" type='checkbox' runat='server' name='chkID'  value='<%# Eval("ID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Menu">
                    <ItemTemplate>
                        <asp:HyperLink ID="lnkMenu" runat="server" Text="Tên menu"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField HeaderText="Link" DataField="Url" />

                <asp:BoundField HeaderText="Danh mục cha" DataField="TenDanhMucCha" />

                <asp:BoundField HeaderText="Hiển thị theo" DataField="Target" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="50" />

                <asp:TemplateField HeaderText="Thứ tự"  ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="60">
                    <ItemTemplate>
                        <div style="width:50%;float:left;">&nbsp;
                            <img src="../Images/Icon/pagination_Down.png" width="16" height="16" style="cursor:pointer;" nameImg="imgOrderDown" onclick="javascript:OrderDown('<%# Eval("ID") %>')"/>
                        </div>
                        <div style="width:50%;float:left;">&nbsp;
                            <img src="../Images/Icon/pagination_Up.png" width="16" height="16" style="cursor:pointer;" nameImg="imgOrderUp" onclick="javascript:OrderUp('<%# Eval("ID") %>')"/>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Trạng Thái" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="70">
                    <ItemTemplate>
                        <asp:Image ID="imgUpdate" runat="server" style="cursor:pointer;"/>
                    </ItemTemplate>
                </asp:TemplateField>

            </Columns>
        </asp:GridView>
    </div>
</div>